package tech.aistar.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Ace
 * @version 1.0
 * @descriiption:本类用来演示:
 * @date 2019/10/10 0010.
 */
@Controller
@RequestMapping("/fun")
public class FunFunctionController {
    /**
     * 转发到狗龄换算jsp
     * @return
     */
    @GetMapping("/function")
    public String function(){
        return "fun-function";
    }
    /**
     * 接受客户端参数,并计算
     */
    @PostMapping("/conversion")
    @ResponseBody
    public String conversion(String dage,String small,String middle,String big){
        double Dage=Double.valueOf(dage);
        System.out.println(small+"==="+middle+"==="+big);
        if (small!=null){
            String data= String.valueOf(24+(Dage-1)*4);
            return data;
        }else if (middle!=null){
            String data= String.valueOf(24+(Dage-1)*4);
            return data;
        }else if (big!=null){
            String data= String.valueOf(12+(Dage-1)*7);
            return data;
        }else{
            return "请勾选体型";
        }

    }
}
